package com.xuecheng.media.api;


import com.xuecheng.content.model.dto.RestResponse;
import com.xuecheng.media.service.MediaFilesService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ApiOperation(value="媒体资源管理接口" ,tags="媒体资源文件接口")
@RestController
@RequestMapping("/open")
public class MediaOpenController {

    @Autowired
    private MediaFilesService mediaFilesService;

    @ApiOperation("获取文件地址")
    @GetMapping("/preview/{mediaId}")
    public RestResponse<String> getFileUrl(@PathVariable Long mediaId){
        String url = mediaFilesService.selectUrlById(mediaId);
        if(url != null){
            return RestResponse.success(url);
        }
        return RestResponse.validfail(url);
    }

}
